|
CAN Gateway code example
v1.2
|
Handling functions for CAN Gateway. More...
#include <cstring>#include <pthread.h>#include <unistd.h>#include <new>#include <hdj2534.h>#include "cangw.hpp"Go to the source code of this file.
Classes | |
| struct | GwParam_s |
| Definition of structure with CAN Gateway's parameters. More... | |
| struct | ThreadParam_s |
| Definition of structure with thread parameters. More... | |
Functions | |
| static ErrCode_e | canGwOpen () |
| Function opens CAN Gateway. More... | |
| static ErrCode_e | canGwClose () |
| Function closes CAN Gateway. More... | |
| static ErrCode_e | canGwConnectChannels () |
| Function connects CAN Gateway's channels. More... | |
| static ErrCode_e | canGwDisconnectChannels () |
| Function disconnects CAN Gateway's channels. More... | |
| static ErrCode_e | canGwSetFilters () |
| Function sets CAN Gateway's message filters. More... | |
| static ErrCode_e | canGwInitRcvThread (Channel_e channel) |
| Function initializes receiving thread for given physical channel. More... | |
| static ErrCode_e | canGwUninitRcvThread (Channel_e channel) |
| Function uninitializes receiving thread for given physical channel. More... | |
| static void * | canGwRcvThreadFunc (void *params) |
| Function handles CAN Gateway's receiving threads. More... | |
Variables | |
| static GwParam_s | gwParam = {0, 0, 0, 0, 0, 0, 0, false, false} |
| Structure with CAN device parameters. | |
| static ThreadParam_s | threadParamCh1 |
| Structure with thread parameters for Channel1. | |
| static ThreadParam_s | threadParamCh2 |
| Structure with thread parameters for Channel2. | |
| static pthread_mutex_t | gwMutex = PTHREAD_MUTEX_INITIALIZER |
| Mutex for CAN Gateway's API. | |
| static RcvCb_t | rcvCbCh1 |
| Receive callback function for Channel 1. | |
| static RcvCb_t | rcvCbCh2 |
| Receive callback function for Channel 2. | |
| static J2534::PASSTHRU_MSG * | rxPassThruMsgCh1 = NULL |
| Pointer to receive buffer with PASSTHRU messages for Channel 1. | |
| static J2534::PASSTHRU_MSG * | rxPassThruMsgCh2 = NULL |
| Pointer to receive buffer with PASSTHRU messages for Channel 2. | |
| static const unsigned int | MAX_RX_MSGS = 20 |
| Maximum number of messages to receive. | |
| static unsigned long | TX_TIMEOUT = 100 |
| Timeout for PassThruWriteMsgs() function. | |
| static const unsigned long | BAUD_VAL_125KBPS = 125000 |
| Value for baud rate = 125 kbps. | |
| static const unsigned long | BAUD_VAL_250KBPS = 250000 |
| Value for baud rate = 250 kbps. | |
| static const unsigned long | BAUD_VAL_500KBPS = 500000 |
| Value for baud rate = 500 kbps. | |
| static const unsigned long | BAUD_VAL_1MBPS = 1000000 |
| Value for baud rate = 1 Mbps. | |
Handling functions for CAN Gateway.
Definition in file cangw.cpp.
|
static |
Function opens CAN Gateway.
Definition at line 304 of file cangw.cpp.
References canGw::CAN_GW_ERR, canGw::CAN_GW_OK, canGwConnectChannels(), canGwSetFilters(), gwParam, and GwParam_s::idDevice.
Referenced by canGw::init().
|
static |
Function closes CAN Gateway.
Definition at line 325 of file cangw.cpp.
References canGw::CAN_GW_ERR, canGw::CAN_GW_OK, canGwDisconnectChannels(), gwParam, and GwParam_s::idDevice.
Referenced by canGw::uninit().
|
static |
Function connects CAN Gateway's channels.
Definition at line 345 of file cangw.cpp.
References GwParam_s::activeCh1, GwParam_s::activeCh2, GwParam_s::baudCh1, GwParam_s::baudCh2, canGw::CAN_GW_ERR, canGw::CAN_GW_OK, gwParam, GwParam_s::idCh1, GwParam_s::idCh2, and GwParam_s::idDevice.
Referenced by canGwOpen().
|
static |
Function disconnects CAN Gateway's channels.
Definition at line 389 of file cangw.cpp.
References GwParam_s::activeCh1, GwParam_s::activeCh2, canGw::CAN_GW_ERR, canGw::CAN_GW_OK, gwParam, GwParam_s::idCh1, and GwParam_s::idCh2.
Referenced by canGwClose().
|
static |
Function sets CAN Gateway's message filters.
Definition at line 428 of file cangw.cpp.
References canGw::CAN_GW_ERR, canGw::CAN_GW_OK, gwParam, GwParam_s::idCh1, GwParam_s::idCh2, GwParam_s::idFilterCh1, and GwParam_s::idFilterCh2.
Referenced by canGwOpen().
Function initializes receiving thread for given physical channel.
| [in] | channel | CAN Gateway's physical channel |
Definition at line 479 of file cangw.cpp.
References ThreadParam_s::active, ThreadParam_s::attr, canGw::CAN_GW_ERR, canGw::CAN_GW_OK, canGwRcvThreadFunc(), canGw::CHANNEL_1, canGw::CHANNEL_2, ThreadParam_s::gwChannel, ThreadParam_s::id, threadParamCh1, and threadParamCh2.
Referenced by canGw::init().
Function uninitializes receiving thread for given physical channel.
| [in] | channel | CAN Gateway's physical channel |
Definition at line 533 of file cangw.cpp.
References ThreadParam_s::active, canGw::CAN_GW_ERR, canGw::CAN_GW_OK, canGw::CHANNEL_1, canGw::CHANNEL_2, ThreadParam_s::id, threadParamCh1, and threadParamCh2.
Referenced by canGw::uninit().
|
static |
Function handles CAN Gateway's receiving threads.
| [in] | params | Pointer to structure ThreadParam_s with thread parameters |
Definition at line 568 of file cangw.cpp.
References canGw::CHANNEL_1, canGw::CHANNEL_2, gwMutex, gwParam, GwParam_s::idCh1, GwParam_s::idCh2, MAX_RX_MSGS, rcvCbCh1, rcvCbCh2, rxPassThruMsgCh1, and rxPassThruMsgCh2.
Referenced by canGwInitRcvThread().
1.8.6